package com.habbot.beautifyinghandbook.adapters;

import java.util.List;

import com.habbot.beautifyinghandbook.R;
import com.habbot.beautifyinghandbook.objects.MenuObject;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainListAdapter extends ArrayAdapter<MenuObject> {

	public MainListAdapter(Context context, int resource,
			List<MenuObject> objects) {
		super(context, resource, objects);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = ((LayoutInflater) getContext().getSystemService(
					Context.LAYOUT_INFLATER_SERVICE)).inflate(
					R.layout.mainlist_item, parent, false);
		}

		TextView tv_title;
		ImageView img_item_icon;
		tv_title = (TextView) convertView.findViewById(R.id.tv_title);
		img_item_icon = (ImageView) convertView
				.findViewById(R.id.img_item_icon);

		MenuObject menuItem = getItem(position);
		img_item_icon.setImageResource(menuItem.getIconRes());
		tv_title.setText(menuItem.getTitle());

		convertView.setTag(menuItem);
		return convertView;
	}

}
